#include <sys_head.h>

int main(int argc, char const *argv[])
{
    // 文件打开
    int fd = open( "lock_file.txt" , O_CREAT | O_RDWR , 0666);


    // 向文件中写入
    char buf[1024];
    int read_byte;
    while (1)
    {
        memset(buf , 0 , sizeof(buf));
        
        //从文件中读取
        read_byte = read(fd , buf , sizeof(buf));
        if (0 == read_byte)
        {
            continue;
        }
        

        if (!strcmp( buf , "quit"))
        {
            close(fd);
            return 0;
        }

        printf("文件读取:%s\n" , buf);
        
    }
    



    // 文件关闭
    close(fd);


    return 0;
}
